package test.study.concurrent.thread._3_future.test;

public class FutureData implements Data {

    RealData realData;

    public synchronized void setRealData(RealData realData) {
        this.realData = realData;

        //TODO RealData 已经被注入，通知 getResult()
        notifyAll();
    }

    @Override
    public synchronized String getResult() {
        try {
            //TODO 一直等待，直到 RealData 被注入
            wait();
        } catch (InterruptedException ex) {
        }
        //真正需要的数据从RealData获取
        return realData.getResult();
    }
}
